#ifndef LINKEDLIST_H
#define LINKEDLIST_H

#include <iostream>
template <typename T>
struct Node
{
    T data;
    Node<T> *next;
};

template <typename T>
class LinkedList
{
    Node<T> *head;
    Node<T> *tail;
    int size;

public:
    LinkedList()
    {
        head = NULL;
        tail = NULL;
        size = 0;
    }

    void push(T data)
    {
        Node<T> *temp = new Node<T>;
        temp->data = data;
        temp->next = NULL;
        if (head == NULL)
        {
            head = temp;
            tail = temp;
            size++;
        }
        else
        {
            tail->next = temp;
            tail = temp;
        }
    }

    void pop()
    {
        if (head == NULL)
        {
            return;
        }
        else
        {
            Node<T> *temp = head;
            head = head->next;
            delete temp;
        }
    }
    void deduplicatePrint()
    {
        Node<T> *current = head;
        while (current != NULL)
        {
            if(current->next == NULL){
                std::cout << current->data << " ";
                break;
            }
            if (current->next->data == current->data)
            {
                current = current->next;
                continue;
            }
            else
            {
                std::cout << current->data << " ";
            }
            current = current->next;
        }
    }
};

#endif // LINKEDLIST_H